import time
import allure
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from page.base_page import BasePage


class ModifyProxyOrderPage(BasePage):
    __FILE_MASK = By.XPATH, "//*[@class = 'el-loading-spinner']"
    __ElE_MASK = By.XPATH, "//*[@class = 'el-loading-mask']"
    __CAPITAL_COMPANY = By.XPATH, "//*[@class= 'el-row scroll-item addrow']//*[text()='请选择资金方']"
    __CAPITAL_PLAN = By.XPATH, "//*[@class= 'el-row scroll-item addrow']//*[text()='请选择配资方案']"
    __PRODUCT_NAME = By.XPATH, "//*[@class= 'el-row scroll-item addrow']//*[text()='请选择产品']"
    __UPLOAD_IDCARD = By.XPATH, "//*[@class = 'el-upload el-upload--text is-drag']/input"
    __NAME = By.XPATH, "//*[@placeholder = '请选择客户']"
    __PHONE = By.XPATH, "//*[@placeholder = '请输入手机号码']"
    __SSN = By.XPATH, "//*[@placeholder = '请输入身份证']"
    __START_DATE = By.XPATH, "//*[@placeholder = '身份证有效起始日期']"
    __END_DATE = By.XPATH, "//*[@placeholder = '身份证有效结束日期']"
    __ID_ADDRESS = By.XPATH, "//*[@placeholder = '请输入身份证地址']"
    __BIRTH_DATE = By.XPATH, "//*[@placeholder = '请选择出生日期']"
    __DURATION = By.XPATH, "//*[text() = '请选择现居地居住年限']"
    __MARRIAGE = By.XPATH, "//*[text() = '请选择婚姻情况']"
    __QUALIFICATION = By.XPATH, "//*[text() = '请选择目前学历']"
    __RESIDENTIAL = By.XPATH, ("//*[@class = 'el-form el-form--default el-form--label-right']/div[2]/div[2]/div[2]//*["
                               "@placeholder='请选择']")
    __ADDRESS = By.XPATH, "//*[@placeholder = '请输入详细地址']"
    __INPUT_FILE = By.XPATH, "//*[@class = 'el-upload el-upload--text']/input"
    __ENTERPRISE_NAME = By.XPATH, "//*[@placeholder = '请输入企业名称']"
    __SOCIAL_CREDIT = By.XPATH, "//*[text() = '信用代码']/../div/div/div/input"
    __JURIDICAL_PERSON = By.XPATH, "//*[text() = '法人姓名']/../div/div/div/input"
    __REGISTERED_CAPITAL = By.XPATH, "//*[@placeholder = '请输入注册资本金']"
    __REGISTRATION_DATE = By.XPATH, "//*[text() = '注册日期']/../div/div/div/input"
    __CORPORATE_IDCARD = By.XPATH, "//*[text() = '法人身份证']/../div/div/div/input"
    __INDUSTRY = By.XPATH, "//*[text() = '所属行业']/../div/div/div"
    __TURNOVER = By.XPATH, "//*[text() = '年营业额']/../div/div/div/input"
    __BUSINESS_ADDRESS = By.XPATH, "//*[text() = '经营地址']/../div/div/div/input"
    __ADD_FILE = By.XPATH, "//*[text()='添加文件']"
    __FILE_CATEGORY = By.XPATH, "//*[text()='请选择附件分类']"
    __FILE_SELECT = By.XPATH, ("//*[@class = 'el-table--fit el-table--border el-table--enable-row-hover "
                               "el-table--enable-row-transition el-table--default el-table el-table--layout-fixed "
                               "is-scrolling-none']//tbody/tr[4]//*[text()='选择文件']")
    __FILE_NAME = By.XPATH, ("//*[@class = 'el-table--fit el-table--border el-table--enable-row-hover "
                             "el-table--enable-row-transition el-table--default el-table el-table--layout-fixed "
                             "is-scrolling-none']//tbody/tr[4]/td[3]/div")
    __DOWNLOAD_FILE = By.XPATH, ("//*[@class = 'el-table--fit el-table--border el-table--enable-row-hover "
                                 "el-table--enable-row-transition el-table--default el-table el-table--layout-fixed "
                                 "is-scrolling-none']//tbody/tr[4]//*[text()='下载']")
    __DELETE_FILE = By.XPATH, ("//*[@class = 'el-table--fit el-table--border el-table--enable-row-hover "
                               "el-table--enable-row-transition el-table--default el-table el-table--layout-fixed "
                               "is-scrolling-none']//tbody/tr[4]//*[text()='删除']")
    __INPUT_ATTACHMENT = By.XPATH, "//*[@aria-label='上传文件']//input"
    __ADD_CONTACT = By.XPATH, "//*[text() = '+ 添加联系人']"
    __CONTACT_NAME = By.XPATH, "//*[@placeholder = '请输入姓名']"
    __CONTACT_PHONE = By.XPATH, "//*[@placeholder = '请输入手机号']"
    __CONTACT_RELATIONSHIP = By.XPATH, "//*[text() = '联系人关系']/.."
    __LOAN_AMOUNT = By.XPATH, "//*[@placeholder = '请输入借款金额']"
    __LOAN_PERIOD = By.XPATH, "//*[@placeholder = '请输入借款期数']"
    __REPAYMENT_METHOD = By.XPATH, "//*[text() = '请选择还款方式']"
    __LOAN_PURPOSE = By.XPATH, "//*[@placeholder = '请输入借贷用途']"
    __BANK_ACCOUNT_NAME = By.XPATH, "//*[@placeholder = '请输入账户名']"
    __OPENING_BANK = By.XPATH, "//*[@placeholder = '请输入开户行']"
    __BANKCARD_NUMBER = By.XPATH, "//*[@placeholder = '请输入收款账户银行卡号']"
    __BANK_PHONE = By.XPATH, "//*[@placeholder = '请输入预留手机号']"
    __SAVE_BUTTON = By.XPATH, "//*[text() = '保存借贷信息']"
    __SUBMIT_BUTTON = By.XPATH, "//*[text() = '确定提交订单']"
    __CANCEL_BUTTON = By.XPATH, "//*[text() = '取 消']"
    __ADD_PROPERTY = By.XPATH, "//*[text() = '+ 添加房产']"
    __MODIFY_PROPERTY = By.XPATH, "//*[text() = '房产信息 ']/../..//*[@class = 'el-table__row']//*[text()='编辑']"
    __PROPERTY_OWNERSHIP_CERTIFICATE = By.XPATH, "//*[text()='房产证']/../..//input"
    __PURCHASE_CONTRACT = By.XPATH, "//*[text()='购房合同']/../..//input"
    __PROPERTY_SURVEY_DATA = By.XPATH, "//*[text()='产调资料']/../..//input"
    __PROPERTY_OWNER_NAME = By.XPATH, "//*[text()='产权人']/../div/div/div/input"
    __PROPERTY_OWNER_IDCARD = By.XPATH, "//*[text()='产权人身份证']/../div/div/div/input"
    __PROPERTY_RIGHT_SHARE = By.XPATH, "//*[text()='产权份额']/../div/div/div/input"
    __PROPERTY_ADDRESS = By.XPATH, "//*[text()='房产地址']/../div/div/div/input"
    __PROPERTY_CITY = By.XPATH, "//*[text()='产权城市']/../div/div/div/input"
    __PROPERTY_NAME = By.XPATH, "//*[text()='楼盘名称']/../div/div/div/input"
    __BUILDING_NUMBER = By.XPATH, "//*[text()='楼宇号']/../div/div/div/input"
    __FLOOR_LOCATION = By.XPATH, "//*[text()='所在楼层']/../div/div/div/input"
    __ROOM_NUMBER = By.XPATH, "//*[text()='房号']/../div/div/div/input"
    __BUILDING_AREA = By.XPATH, "//*[text()='建筑面积']/../div/div/div/input"
    __OWNERSHIP_CERTIFICATE = By.XPATH, "//*[text()='权属证书编号']/../div/div/div/input"
    __EVALUATE_VALUE = By.XPATH, "//*[text()='评估价值']/../div/div/div/input"
    __PROPERTY_OWNER_PHONE = By.XPATH, "//*[text()='产权人手机号码']/../div/div/div/input"
    __PROPERTY_OWNER_ADDRESS = By.XPATH, "//*[text()='产权人地址']/../div/div/div/input"
    __MARITAL_STATUS = By.XPATH, "//*[text()='婚姻状态']/../div/div/div"
    __BELONG_REGION = By.XPATH, "//*[text()='所属区域']/../div/div/div/input"
    __POWER_VALUE = By.XPATH, "//*[text()='权力价值']/../div/div/div/input"
    __MORTGAGE_RATE = By.XPATH, "//*[text()='抵押率']/../div/div/div/input"
    __ADD_PROPERTY_OK = By.XPATH, "//*[@class = 'el-button el-button--primary el-button--default']//*[text()='确定']"
    __PROPERTY_FIRST_INFO_NAME = By.XPATH, "//*[text() = '房产信息 ']/../..//*[@class = 'el-table__row']/td[2]"
    __DELETE_FIRST_PROPERTY = By.XPATH, "//*[text() = '房产信息 ']/../..//*[@class = 'el-table__row']//*[text()='删除']"
    __DELETE_SECOND_OK = By.XPATH, "//*[@aria-label ='系统提示']//*[text()='确定']"
    __MESSAGE = By.XPATH, "//*[@class = 'el-message__content']"
    __DELETE_SUCCESSFULLY_MESSAGE = By.XPATH, "//*[text() = '删除成功！']"

    def select_capital_info(self, capital_company, capital_plan, product_name):
        self.find_and_click(self.__CAPITAL_COMPANY)
        self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{capital_company}']")
        self.find_and_click(self.__CAPITAL_PLAN)
        self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{capital_plan}']")
        self.find_and_click(self.__PRODUCT_NAME)
        self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{product_name}']")
        return ModifyProxyOrderPage(self.driver)

    def input_borrower_info(self, idcard_front=None, idcard_back=None, name=None, gender=None, phone=None, ssn=None,
                            start_date=None, end_date=None, id_address=None, birth_date=None, domicile=None,
                            duration=None, marriage=None, qualification=None, residential=None, address=None):
        if idcard_front is not None and idcard_back is not None:
            ele = self.finds(self.__UPLOAD_IDCARD)
            with allure.step("上传身份证正面"):
                ele[0].send_keys(idcard_front)
                self.wait(EC.staleness_of(self.find(self.__ElE_MASK)), time_out=10)
            with allure.step("上传身份证反面"):
                ele[1].send_keys(idcard_back)
                self.wait(EC.staleness_of(self.find(self.__ElE_MASK)), time_out=10)
        if name is not None:
            with allure.step(f"输入姓名为{name}"):
                self.find(self.__NAME).clear()
                self.find_and_send(self.__NAME, text=name)
        if gender is not None:
            with allure.step(f"选择性别为{gender}"):
                self.find_and_click(By.XPATH, f"//*[@class = 'el-radio-group ml-4']//*[text()='{gender}']")
        if phone is not None:
            with allure.step(f"输入手机号为{phone}"):
                self.find(self.__PHONE).clear()
                self.find_and_send(self.__PHONE, text=phone)
        if ssn is not None:
            with allure.step(f"输入身份证号为{ssn}"):
                self.find(self.__SSN).clear()
                self.find_and_send(self.__SSN, text=ssn)
        if start_date is not None:
            with allure.step(f"选择身份证有效日期为{start_date}"):
                self.find(self.__START_DATE).clear()
                self.find_and_send(self.__START_DATE, text=start_date)
        if end_date is not None:
            with allure.step(f"选择身份证有效结束日期为{end_date}"):
                self.find(self.__END_DATE).clear()
                self.find_and_send(self.__END_DATE, text=end_date)
        if id_address is not None:
            with allure.step(f"输入身份证地址为{id_address}"):
                self.find(self.__ID_ADDRESS).clear()
                self.find_and_send(self.__ID_ADDRESS, text=id_address)
        if birth_date is not None:
            with allure.step(f"选择出生日期为{birth_date}"):
                self.find(self.__BIRTH_DATE).clear()
                self.find_and_send(self.__BIRTH_DATE, text=birth_date)
        if domicile is not None:
            with allure.step(f"选择户籍为{domicile}"):
                self.find_and_click(By.XPATH, f"//*[@class = 'el-radio-group ml-4']//*[text()='{domicile}']")
        if duration is not None:
            with allure.step(f"选择现居地居住年限为{duration}"):
                self.find_and_click(self.__DURATION)
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text()='{duration}']")
        if marriage is not None:
            with allure.step(f"选择婚姻情况为{marriage}"):
                self.find_and_click(self.__MARRIAGE)
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{marriage}']")
        if qualification is not None:
            with allure.step(f"选择目前学历为{qualification}"):
                self.find_and_click(self.__QUALIFICATION)
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{qualification}']")
        if residential is not None:
            with allure.step(f"选择现居住地为{residential}"):
                self.find_and_click(self.__RESIDENTIAL)
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{residential[0]}']")
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{residential[1]}']")
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{residential[2]}']")
        if address is not None:
            with allure.step(f"输入详细地址为{address}"):
                self.find(self.__ADDRESS).clear()
                self.find_and_send(self.__ADDRESS, text=address)
        return ModifyProxyOrderPage(self.driver)

    def input_work_unit_info(self, customer_category, business_license=None, enterprise_name=None, social_credit=None,
                             juridical_person=None,
                             registered_capital=None, registration_date=None, corporate_idcard=None, industry=None,
                             turnover=None, business_address=None):
        if customer_category == "自雇":
            with allure.step("选择客户类别为自雇"):
                self.find_and_click(By.XPATH, f"//*[text()='{customer_category}']")
            if business_license is not None:
                with allure.step("上传营业执照"):
                    ele = self.finds(self.__INPUT_FILE)
                    ele[0].send_keys(business_license)
                    self.wait(EC.staleness_of(self.find(self.__ElE_MASK)), time_out=20)
            if enterprise_name is not None:
                with allure.step(f"输入企业名称{enterprise_name}"):
                    self.find(self.__ENTERPRISE_NAME).clear()
                    self.find_and_send(self.__ENTERPRISE_NAME, text=enterprise_name)
            if social_credit is not None:
                with allure.step(f"输入社会信用代码{social_credit}"):
                    self.find(self.__SOCIAL_CREDIT).clear()
                    self.find_and_send(self.__SOCIAL_CREDIT, text=social_credit)
            if juridical_person is not None:
                with allure.step(f"输入法人姓名{juridical_person}"):
                    self.find(self.__JURIDICAL_PERSON).clear()
                    self.find_and_send(self.__JURIDICAL_PERSON, text=juridical_person)
            if registered_capital is not None:
                with allure.step(f"输入注册资本金{registered_capital}"):
                    self.find(self.__REGISTERED_CAPITAL).clear()
                    self.find_and_send(self.__REGISTERED_CAPITAL, text=registered_capital)
            if registration_date is not None:
                with allure.step(f"输入注册日期{registration_date}"):
                    self.find(self.__REGISTRATION_DATE).clear()
                    self.find_and_send(self.__REGISTRATION_DATE, text=registration_date)
            if corporate_idcard is not None:
                with allure.step(f"输入法人身份证 {corporate_idcard}"):
                    self.find(self.__CORPORATE_IDCARD).clear()
                    self.find_and_send(self.__CORPORATE_IDCARD, text=corporate_idcard)
            if industry is not None:
                with allure.step(f"输入所属行业{industry}"):
                    self.find_and_click(self.__INDUSTRY)
                    self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{industry}']")
            if turnover is not None:
                with allure.step(f"输入营业额{turnover}"):
                    self.find(self.__TURNOVER).clear()
                    self.find_and_send(self.__TURNOVER, text=turnover)
            if business_address is not None:
                with allure.step(f"输入经营地址{business_address}"):
                    self.find(self.__BUSINESS_ADDRESS).clear()
                    self.find_and_send(self.__BUSINESS_ADDRESS, text=business_address)
            return ModifyProxyOrderPage(self.driver)
        else:
            with allure.step("选择客户类别为授薪"):
                self.find_and_click(By.XPATH, f"//*[text()='{customer_category}']")
                return ModifyProxyOrderPage(self.driver)

    def input_contract_info(self, contract_name1, contract_phone1, contract_relationship1, contract_name2,
                            contract_phone2, contract_relationship2, contract_name3, contract_phone3,
                            contract_relationship3):
        with allure.step("点击添加联系人1"):
            self.find_and_click(self.__ADD_CONTACT)
        with allure.step(f"输入联系人1姓名为{contract_name1}"):
            self.find_and_send(self.__CONTACT_NAME, text=contract_name1)
        with allure.step(f"输入联系人1手机号为{contract_phone1}"):
            self.find_and_send(self.__CONTACT_PHONE, text=contract_phone1)
        with allure.step(f"选择联系人1关系为{contract_relationship1}"):
            self.find_and_click(self.__CONTACT_RELATIONSHIP)
            self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{contract_relationship1}']")
        with allure.step("点击添加联系人2"):
            self.find_and_click(self.__ADD_CONTACT)
        with allure.step(f"输入联系人2姓名为{contract_name2}"):
            ele = self.finds(self.__CONTACT_NAME)
            ele[1].send_keys(contract_name2)
        with allure.step(f"输入联系人2手机号为{contract_phone2}"):
            ele = self.finds(self.__CONTACT_PHONE)
            ele[1].send_keys(contract_phone2)
        with allure.step(f"选择联系人2关系为{contract_relationship2}"):
            ele = self.finds(self.__CONTACT_RELATIONSHIP)
            ele[1].click()
            self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{contract_relationship2}']")
        with allure.step("点击添加联系人3"):
            self.find_and_click(self.__ADD_CONTACT)
        with allure.step(f"输入联系人3姓名为{contract_name3}"):
            ele = self.finds(self.__CONTACT_NAME)
            ele[2].send_keys(contract_name3)
        with allure.step(f"输入联系人3手机号为{contract_phone3}"):
            ele = self.finds(self.__CONTACT_PHONE)
            ele[2].send_keys(contract_phone3)
        with allure.step(f"选择联系人3关系为{contract_relationship3}"):
            ele = self.finds(self.__CONTACT_RELATIONSHIP)
            ele[2].click()
            self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{contract_relationship3}']")
        return ModifyProxyOrderPage(self.driver)

    def work_unit_upload_attachments(self, file_category, file):
        with allure.step("点击添加文件"):
            self.find_and_click(self.__ADD_FILE)
        with allure.step("选择附件分类"):
            self.find_and_click(self.__FILE_CATEGORY)
            self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{file_category}']")
        with allure.step("点击选择文件"):
            self.find_and_click(self.__FILE_SELECT)
        with allure.step("上传文件"):
            self.find_and_send(self.__INPUT_ATTACHMENT, text=file)
            self.wait(EC.staleness_of(self.find(self.__FILE_MASK)), time_out=20)
        return ModifyProxyOrderPage(self.driver)

    def get_work_unit_attachments(self):
        with allure.step("获取上传后的文件名"):
            result = self.find(self.__FILE_NAME).text
        return result

    def download_work_unit_attachments(self):
        with allure.step("点击下载文件"):
            self.find_and_click(self.__DOWNLOAD_FILE)
        return ModifyProxyOrderPage(self.driver)

    def delete_work_unit_attachments(self):
        with allure.step("点击删除文件"):
            self.find_and_click(self.__DELETE_FILE)
            return self.wait(EC.invisibility_of_element_located(self.__DELETE_FILE))

    def input_borrow_info(self, loan_amount=None, loan_period=None, repayment_method=None, loan_purpose=None,
                          bankcard_front=None, bankcard_back=None, bank_account_name=None, opening_bank=None,
                          bankcard_number=None, bank_phone=None, customer_category=None):
        if loan_amount is not None:
            with allure.step(f"输入借款金额{loan_amount}"):
                self.find(self.__LOAN_AMOUNT).clear()
                self.find_and_send(self.__LOAN_AMOUNT, text=loan_amount)
        if loan_period is not None:
            with allure.step(f"输入借款期数{loan_period}"):
                self.find(self.__LOAN_PERIOD).clear()
                self.find_and_send(self.__LOAN_PERIOD, text=loan_period)
        if repayment_method is not None:
            with allure.step(f"选择还款方式为{repayment_method}"):
                self.find_and_click(self.__REPAYMENT_METHOD)
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{repayment_method}']")
        if loan_purpose is not None:
            with allure.step(f"输入借贷用途为{loan_purpose}"):
                self.find(self.__LOAN_PURPOSE).clear()
                self.find_and_send(self.__LOAN_PURPOSE, text=loan_purpose)
        if (bankcard_front or bankcard_back) is not None:
            ele = self.finds(self.__INPUT_FILE)
            if bankcard_front is not None:
                with allure.step("上传银行卡正面"):
                    if customer_category == "自雇":
                        ele[1].send_keys(bankcard_front)
                    else:
                        ele[0].send_keys(bankcard_front)
                        self.wait(EC.staleness_of(self.find(self.__ElE_MASK)), time_out=10)
                        time.sleep(0.5)
            if bankcard_back is not None:
                with allure.step("上传银行卡反面"):
                    if customer_category == "自雇":
                        ele[2].send_keys(bankcard_back)
                    else:
                        ele[1].send_keys(bankcard_back)
        if bank_account_name is not None:
            with allure.step(f"输入银行账户名{bank_account_name}"):
                self.find(self.__BANK_ACCOUNT_NAME).clear()
                self.find_and_send(self.__BANK_ACCOUNT_NAME, text=bank_account_name)
        if opening_bank is not None:
            with allure.step(f"输入开户行{opening_bank}"):
                self.find(self.__OPENING_BANK).clear()
                self.find_and_send(self.__OPENING_BANK, text=opening_bank)
        if bankcard_number is not None:
            with allure.step(f"输入银行卡号{bankcard_number}"):
                self.find(self.__BANKCARD_NUMBER).clear()
                self.find_and_send(self.__BANKCARD_NUMBER, text=bankcard_number)
        if bank_phone is not None:
            with allure.step(f"输入银行预留手机号{bank_phone}"):
                self.find(self.__BANK_PHONE).clear()
                self.find_and_send(self.__BANK_PHONE, text=bank_phone)
        return ModifyProxyOrderPage(self.driver)

    def save_button(self):
        with allure.step("点击保存借贷信息"):
            self.find_and_click(self.__SAVE_BUTTON)
            return ModifyProxyOrderPage(self.driver)

    def submit_button(self):
        from page.proxy_order_apply_page import ProxyOrderApply
        with allure.step("点击确定提交订单"):
            self.find_and_click(self.__SUBMIT_BUTTON)
            time.sleep(0.5)
            return ProxyOrderApply(self.driver)

    def cancel_button(self):
        from page.proxy_order_apply_page import ProxyOrderApply
        with allure.step("点击取消"):
            self.find_and_click(self.__CANCEL_BUTTON)
            return ProxyOrderApply(self.driver)

    def get_error_message(self, model):
        with allure.step(f"获取{model}输入框的错误信息"):
            error_message = self.find(By.XPATH,
                                      f"//*[text() = '{model}']/../div/*[@class = 'el-form-item__error']").text
        return error_message

    def get_input_value(self, model):
        with allure.step(f"获取{model}输入框已输入的值"):
            input_value = self.find(By.XPATH, f"//*[text() = '{model}']/../div/div/div/input").get_attribute("value")
        return input_value

    def add_property_info(self, property_ownership_certificate=None, purchase_contract=None, property_survey_data=None,
                          property_owner_name=None, property_owner_idcard=None, property_right_share=None,
                          property_address=None, property_city=None, property_name=None, building_number=None,
                          floor_location=None, room_number=None, building_area=None, ownership_certificate=None,
                          property_owner_address=None, evaluate_value=None, property_owner_phone=None,
                          marital_status=None, belong_region=None, power_value=None, mortgage_rate=None):
        with allure.step("点击新增房产信息"):
            self.find_and_click(self.__ADD_PROPERTY)
        if property_ownership_certificate is not None:
            with allure.step("上传房产证"):
                self.find_and_send(self.__PROPERTY_OWNERSHIP_CERTIFICATE, text=property_ownership_certificate)
        if purchase_contract is not None:
            with allure.step("上传购房合同"):
                self.find_and_send(self.__PURCHASE_CONTRACT, text=purchase_contract)
        if property_survey_data is not None:
            with allure.step("上传产调资料"):
                self.find_and_send(self.__PROPERTY_SURVEY_DATA, text=property_survey_data)
        if property_owner_name is not None:
            with allure.step(f"输入产权人{property_owner_name}"):
                self.find_and_send(self.__PROPERTY_OWNER_NAME, text=property_owner_name)
        if property_owner_idcard is not None:
            with allure.step(f"输入产权人身份证{property_owner_idcard}"):
                self.find_and_send(self.__PROPERTY_OWNER_IDCARD, text=property_owner_idcard)
        if property_right_share is not None:
            with allure.step(f"输入产权份额{property_right_share}"):
                self.find_and_send(self.__PROPERTY_RIGHT_SHARE, text=property_right_share)
        if property_address is not None:
            with allure.step(f"输入房产地址{property_address}"):
                self.find_and_send(self.__PROPERTY_ADDRESS, text=property_address)
        if property_city is not None:
            with allure.step(f"输入产权城市{property_city}"):
                self.find_and_send(self.__PROPERTY_CITY, text=property_city)
        if property_name is not None:
            with allure.step(f"输入楼盘名称{property_name}"):
                self.find_and_send(self.__PROPERTY_NAME, text=property_name)
        if building_number is not None:
            with allure.step(f"输入楼宇号{building_number}"):
                self.find_and_send(self.__BUILDING_NUMBER, text=building_number)
        if floor_location is not None:
            with allure.step(f"输入所在楼层{floor_location}"):
                self.find_and_send(self.__FLOOR_LOCATION, text=floor_location)
        if room_number is not None:
            with allure.step(f"输入房号{room_number}"):
                self.find_and_send(self.__ROOM_NUMBER, text=room_number)
        if building_area is not None:
            with allure.step(f"输入建筑面积{building_area}"):
                self.find_and_send(self.__BUILDING_AREA, text=building_area)
        if ownership_certificate is not None:
            with allure.step(f"输入权属证书编号{ownership_certificate}"):
                self.find_and_send(self.__OWNERSHIP_CERTIFICATE, text=ownership_certificate)
        if evaluate_value is not None:
            with allure.step(f"输入评估价值{evaluate_value}"):
                self.find_and_send(self.__EVALUATE_VALUE, text=evaluate_value)
        if property_owner_phone is not None:
            with allure.step(f"输入产权人手机号{property_owner_phone}"):
                self.find_and_send(self.__PROPERTY_OWNER_PHONE, text=property_owner_phone)
        if property_owner_address is not None:
            with allure.step(f"输入产权人地址{property_owner_address}"):
                self.find_and_send(self.__PROPERTY_OWNER_ADDRESS, text=property_owner_address)
        if marital_status is not None:
            with allure.step(f"选择婚姻状况{marital_status}"):
                self.find_and_click(self.__MARITAL_STATUS)
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{marital_status}']")
        if belong_region is not None:
            with allure.step(f"输入所属区域{belong_region}"):
                self.find_and_send(self.__BELONG_REGION, text=belong_region)
        if power_value is not None:
            with allure.step(f"输入权力价值{power_value}"):
                self.find_and_send(self.__POWER_VALUE, text=power_value)
        if mortgage_rate is not None:
            with allure.step(f"输入抵押率{mortgage_rate}"):
                self.find_and_send(self.__MORTGAGE_RATE, text=mortgage_rate)
        return ModifyProxyOrderPage(self.driver)

    def add_property_info_ok(self):
        with allure.step("点击确认,提交房产信息"):
            self.find_and_click(self.__ADD_PROPERTY_OK)
        return ModifyProxyOrderPage(self.driver)

    def get_property_first_info_name(self):
        with allure.step("获取房产信息第一行产权人姓名"):
            time.sleep(0.2)
            property_first_info_name = self.find(self.__PROPERTY_FIRST_INFO_NAME).text
        return property_first_info_name

    def delete_first_property_info(self):
        with allure.step("删除第一条房产信息"):
            self.find_and_click(self.__DELETE_FIRST_PROPERTY)
            self.find_and_click(self.__DELETE_SECOND_OK)
        try:
            self.wait(EC.visibility_of_element_located(self.__DELETE_SUCCESSFULLY_MESSAGE))
            return True
        except:
            return False

    def modify_property_info(self, property_ownership_certificate=None, property_owner_idcard=None,
                             property_owner_name=None, property_owner_phone=None, property_owner_address=None,
                             ownership_certificate=None, property_address=None, building_area=None,
                             evaluate_value=None,
                             marital_status=None, belong_region=None, power_value=None, mortgage_rate=None):
        with allure.step("点击修改房产"):
            self.find_and_click(self.__MODIFY_PROPERTY)
        if property_ownership_certificate is not None:
            with allure.step("上传房产证"):
                self.find_and_send(self.__PROPERTY_OWNERSHIP_CERTIFICATE, text=property_ownership_certificate)
        if property_owner_idcard is not None:
            with allure.step(f"输入产权人证件号码{property_owner_idcard}"):
                self.find(self.__PROPERTY_OWNER_IDCARD).clear()
                self.find_and_send(self.__PROPERTY_OWNER_IDCARD, text=property_owner_idcard)
        if property_owner_name is not None:
            with allure.step(f"输入产权人姓名{property_owner_name}"):
                self.find(self.__PROPERTY_OWNER_NAME).clear()
                self.find_and_send(self.__PROPERTY_OWNER_NAME, text=property_owner_name)
        if property_owner_phone is not None:
            with allure.step(f"输入产权人手机号{property_owner_phone}"):
                self.find(self.__PROPERTY_OWNER_PHONE).clear()
                self.find_and_send(self.__PROPERTY_OWNER_PHONE, text=property_owner_phone)
        if property_owner_address is not None:
            self.find(self.__PROPERTY_OWNER_ADDRESS).clear()
            with allure.step(f"输入产权人地址{property_owner_address}"):
                self.find_and_send(self.__PROPERTY_OWNER_ADDRESS, text=property_owner_address)
        if ownership_certificate is not None:
            with allure.step(f"输入权属证书编号{ownership_certificate}"):
                self.find(self.__OWNERSHIP_CERTIFICATE).clear()
                self.find_and_send(self.__OWNERSHIP_CERTIFICATE, text=ownership_certificate)
        if property_address is not None:
            with allure.step(f"输入房产地址{property_address}"):
                self.find(self.__PROPERTY_ADDRESS).clear()
                self.find_and_send(self.__PROPERTY_ADDRESS, text=property_address)
        if building_area is not None:
            with allure.step(f"输入建筑面积{building_area}"):
                self.find(self.__BUILDING_AREA).clear()
                self.find_and_send(self.__BUILDING_AREA, text=building_area)
        if evaluate_value is not None:
            with allure.step(f"输入评估价值{evaluate_value}"):
                self.find(self.__EVALUATE_VALUE).clear()
                self.find_and_send(self.__EVALUATE_VALUE, text=evaluate_value)
        if marital_status is not None:
            with allure.step(f"选择婚姻状况{marital_status}"):
                self.find_and_click(self.__MARITAL_STATUS)
                self.find_and_click(By.XPATH, f"//div[@aria-hidden = 'false']//span[text() = '{marital_status}']")
        if belong_region is not None:
            with allure.step(f"输入所属区域{belong_region}"):
                self.find(self.__BELONG_REGION).clear()
                self.find_and_send(self.__BELONG_REGION, text=belong_region)
        if power_value is not None:
            with allure.step(f"输入权力价值{power_value}"):
                self.find(self.__POWER_VALUE).clear()
                self.find_and_send(self.__POWER_VALUE, text=power_value)
        if mortgage_rate is not None:
            with allure.step(f"输入抵押率{mortgage_rate}"):
                self.find(self.__MORTGAGE_RATE).clear()
                self.find_and_send(self.__MORTGAGE_RATE, text=mortgage_rate)
        return ModifyProxyOrderPage(self.driver)

    def get_message(self):
        with allure.step("获取提示信息"):
            message = self.find(self.__MESSAGE).text
        return message
